//
// Created by mongobaba on 2021/6/8.
//

#include "unit_test.h"
#include "json_validator.h"

// 特殊情况
TEST(parse_members_empty) {
    json_validator validator("");
    ASSERT_EQ(false, validator.parse_members());
    ASSERT_EQ(std::string(""), validator.left());
}

// 单个member
TEST(parse_members_single_member) {
    json_validator validator(R"("name":"Tom"x)");
    ASSERT_EQ(true, validator.parse_members());
    ASSERT_EQ(std::string("x"), validator.left());
}

// 多个member
TEST(parse_members_multi_members) {
    // 包括逗号前后都无空白，前面有空白，后面有空白，前后都有空白几种情况
    json_validator validator(R"("a":0,"b":1 ,"c":2, "d":3 , "e":4x)");
    ASSERT_EQ(true, validator.parse_members());
    ASSERT_EQ(std::string("x"), validator.left());
}

// 异常情况，逗号后面无member
TEST(parse_members_no_member_after_comma) {
    json_validator validator(R"("name":"Tom",x)");
    ASSERT_EQ(false, validator.parse_members());
    ASSERT_EQ(std::string("x"), validator.left());
}
